package cn.beatuty.makeup.module.system.dal.mysql.shoppingcart;

import java.util.*;

import cn.beatuty.makeup.framework.common.pojo.PageResult;
import cn.beatuty.makeup.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.beatuty.makeup.framework.mybatis.core.mapper.BaseMapperX;
import cn.beatuty.makeup.module.system.controller.admin.shoppingcart.vo.ShoppingCartPageReqVO;
import cn.beatuty.makeup.module.system.dal.dataobject.shoppingcart.ShoppingCartDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 购物车 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ShoppingCartMapper extends BaseMapperX<ShoppingCartDO> {

    default PageResult<ShoppingCartDO> selectPage(ShoppingCartPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShoppingCartDO>()
                .likeIfPresent(ShoppingCartDO::getProductName, reqVO.getProductName())
                .eqIfPresent(ShoppingCartDO::getProductImage, reqVO.getProductImage())
                .eqIfPresent(ShoppingCartDO::getProductSpecification, reqVO.getProductSpecification())
                .eqIfPresent(ShoppingCartDO::getQuantity, reqVO.getQuantity())
                .eqIfPresent(ShoppingCartDO::getPrice, reqVO.getPrice())
                .neIfPresent(ShoppingCartDO::getPaymentStatus, '2')
                .betweenIfPresent(ShoppingCartDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShoppingCartDO::getId));
    }

}